﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CAEXCollectionView.xaml.cs" >
//   J. Prinz
// </copyright>
// <summary>
//   Interaktionslogik für CAEXCollectionView.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace AutomationMLMapper.Controls
{
    using System.Windows;
    using System.Windows.Data;

    /// <summary>
    ///   Interaktionslogik für CAEXCollectionView.xaml
    /// </summary>
    public partial class CAEXCollectionView
    {
        #region Static Fields

        /// <summary>
        ///   Dependency Property for AllowAdd
        /// </summary>
        public static readonly DependencyProperty AllowAddProperty = DependencyProperty.Register(
            "AllowAdd", typeof(bool), typeof(CAEXCollectionView), new PropertyMetadata(true));

        /// <summary>
        ///   Dependency Property for AllowDelete
        /// </summary>
        public static readonly DependencyProperty AllowDeleteProperty = DependencyProperty.Register(
            "AllowDelete", typeof(bool), typeof(CAEXCollectionView), new PropertyMetadata(true));

        /// <summary>
        ///   Dependency Property for AllowEditElement
        /// </summary>
        public static readonly DependencyProperty AllowEditElementProperty =
            DependencyProperty.Register(
                "AllowEditElement", typeof(bool), typeof(CAEXCollectionView), new PropertyMetadata(true));

        /// <summary>
        ///   Dependency Property for the ButtonAddToolTipDescription
        /// </summary>
        public static readonly DependencyProperty ButtonAddToolTipDescriptionProperty =
            DependencyProperty.Register(
                "AddToolTipDescription", typeof(string), typeof(CAEXCollectionView), new PropertyMetadata("add"));

        /// <summary>
        ///   Dependency Property for the ButtonDeleteToolTipDescription
        /// </summary>
        public static readonly DependencyProperty ButtonDeleteToolTipDescriptionProperty =
            DependencyProperty.Register(
                "DeleteToolTipDescription", typeof(string), typeof(CAEXCollectionView), new PropertyMetadata("delete"));

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CAEXCollectionView"/> class. 
        /// Constructor initializes the ui and sets property bindings on the AllowAdd and AllowDelete Properties
        /// </summary>
        public CAEXCollectionView()
        {
            this.InitializeComponent();

            this.CommandButtons.SetBinding(
                AddDeleteItemControl.AllowAddProperty, new Binding("AllowAdd") { Source = this });
            this.CommandButtons.SetBinding(
                AddDeleteItemControl.AllowDeleteProperty, new Binding("AllowDelete") { Source = this });
            this.CommandButtons.SetBinding(
                AddDeleteItemControl.ButtonAddToolTipDescriptionProperty, 
                new Binding("AddToolTipDescription") { Source = this });
            this.CommandButtons.SetBinding(
                AddDeleteItemControl.ButtonDeleteToolTipDescriptionProperty, 
                new Binding("DeleteToolTipDescription") { Source = this });
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///   ToolTip-Description, associated to the Add Command Button
        /// </summary>
        public string AddToolTipDescription
        {
            get
            {
                return (string)this.GetValue(ButtonAddToolTipDescriptionProperty);
            }

            set
            {
                this.SetValue(ButtonAddToolTipDescriptionProperty, value);
            }
        }

        /// <summary>
        ///   Allow Execution of the Add Command
        /// </summary>
        public bool AllowAdd
        {
            get
            {
                return (bool)this.GetValue(AllowAddProperty);
            }

            set
            {
                this.SetValue(AllowAddProperty, value);
            }
        }

        /// <summary>
        ///   Allow Execution of the Delete Command
        /// </summary>
        public bool AllowDelete
        {
            get
            {
                return (bool)this.GetValue(AllowDeleteProperty);
            }

            set
            {
                this.SetValue(AllowDeleteProperty, value);
            }
        }

        /// <summary>
        ///   Allow Execution of the Edit Command, responsible for the selection of an editable data Template for the Elements of the collection
        /// </summary>
        public bool AllowEditElement
        {
            get
            {
                return (bool)this.GetValue(AllowEditElementProperty);
            }

            set
            {
                this.SetValue(AllowEditElementProperty, value);
            }
        }

        /// <summary>
        ///   ToolTip-Description, associated to the Delete Command Button
        /// </summary>
        public string DeleteToolTipDescription
        {
            get
            {
                return (string)this.GetValue(ButtonDeleteToolTipDescriptionProperty);
            }

            set
            {
                this.SetValue(ButtonDeleteToolTipDescriptionProperty, value);
            }
        }

        #endregion
    }
}